global path "/Users/eborbath/Nextcloud/Papers/Blauer_Band/Empirical_analysis/"

use "${path}/Data/GLES/elect13_17_21.dta", clear

// First with the post-election surveys

factor issue_* pos_tax pos_migran if year==2013 & post==1, pcf factor(2) bl(0.2)
	
rotate, bl(0.2)

predict factor13a factor13b if year==2013 & post==1

factor issue_* pos_tax pos_migran if year==2017 & post==1, pcf factor(2) bl(0.2)

rotate, bl(0.2)

predict factor17b factor17a if year==2017 & post==1

factor issue_* pos_tax pos_migran if year==2021 & post==1, pcf factor(2) bl(0.2)

rotate, bl(0.2)

predict factor21b factor21a if year==2021 & post==1

gen factor_econ=.
replace factor_econ=factor13a if year==2013 & post==1
replace factor_econ=factor17a if year==2017 & post==1
replace factor_econ=factor21a if year==2021 & post==1

gen factor_cult=.
replace factor_cult=factor13b if year==2013 & post==1
replace factor_cult=factor17b if year==2017 & post==1
replace factor_cult=factor21b if year==2021 & post==1

keep if post==1

keep id factor_econ factor_cult

save "${path}/Data/GLES/factor_scores.dta", replace


